<#include "../common/layout/__mainlayout.html">
<#include "../common/__pagination.html">

    <!--设置面包屑-->
    <#assign pageBreadCrumbs>
        <li class="active"><a href="#">应用推荐</a></li>
        <li class="active"><a href="#">搜索推广管理</a></li>
    </#assign>
    <#assign pageCss>
        <!-- page specific plugin styles -->
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/jquery-ui.custom.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/chosen.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/datepicker.css"/>
        <link rel="stylesheet" href="${ctx}/static/admin/assets/css/daterangepicker.css"/>
    </#assign>

    <#assign pageJavascript>
        <script type="text/javascript">
            $(document).ready(function () {
                $("#generalType").val(${query.generalType!});

                $('[data-rel=tooltip]').tooltip();

                if (!ace.vars['touch']) {
                    $('.chosen-select').chosen({allow_single_deselect: true});
                }


                //初始化范围选择器
                $('input[name=generalDateRange]').daterangepicker({
                    'applyClass' : 'btn-sm btn-success',
                    'cancelClass' : 'btn-sm btn-default',
                    locale: {
                        applyLabel: '确定',
                        cancelLabel: '取消',
                    }
                })

                // 清除远程modal数据
                $("#editModal").on("hidden.bs.modal", function () {
                    $(this).removeData("bs.modal");
                });

                // 删除按钮
                $("a.delete").on(ace.click_event, function (e) {
                    var currentA = this;
                    e.preventDefault();
//                bootbox.setDefaults({locale:"zh_CN"});
                    bootbox.confirm({
                                message: "确定删除该用户?",
                                buttons: {
                                    confirm: {
                                        label: "确定",
                                        className: "btn-primary btn-sm"
                                    },
                                    cancel: {
                                        label: "取消",
                                        className: "btn-sm"
                                    }
                                },
                                callback: function (result) {
                                    if (result) {
                                        if (result) {
                                            url = $(currentA).attr("href");
                                            $.get(url, { },function(data){
                                                if(data){
                                                    window.location.href=window.location.href;
                                                }
                                            });
                                        }
                                    }
                                }
                            }
                    );
                });
            });
        </script>
    </#assign>

    <@mainlayout pageBreadCrumbs=pageBreadCrumbs pageCss=pageCss pageJavascript=pageJavascript
    currentMenu="recommendFlag-generalFlag">
    <div class="row">
        <div class="col-xs-12">
            <form id="searchForm" class="form-search form-inline" action="/admin/general/list.do">
                <div class="form-group  col-xs-12" style="padding-top:10px">
                    <label class="col-xs-1 text-right" for="generalType">推广类型:</label>
                    <select class="col-xs-2"  name="generalType" id="generalType" data-placeholder="Choose a State...">
                        <option value="-1">请选择类型</option>
                        <option value="0">搜索关键字</option>
                        <option value="1">软件</option>
                        <option value="2">专题</option>
                        <option value="4">外链</option>
                    </select>

                    <label class="col-xs-1 text-right" for="generalDateRange">推广开始时间:</label>
                    <div class="input-medium input-group">
                        <input class="form-control" type="text" class="input-sm input-small" value="${query.generalDateRange!}" 　 name="generalDateRange" id="generalDateRange"/>
                    </div>
                    <input type="submit" id="searchBtn" class="btn btn-sm btn-primary" value="查询"/>&nbsp;
                    <a onclick='reload("${ctx}/admin/general/add.do");return false;'  class="btn btn-sm btn-warning" ><i class="ace-icon fa fa-plus"></i>添加</a>
                </div>
                <hr>
                <table id="contentTable" class="table table-striped table-bordered table-hover">
                <thead>
                <tr>
                    <th width="40" align="center">推广编号</th>
                    <th width="100" align="left">开始时间</th>
                    <th width="70" align="left">结束时间</th>
                    <th width="70" align="left">推广类型</th>
                    <th width="70" align="left">软件ID/专题ID/关键字/外链</th>
                    <th width="40" align="center">操作</th>
                </tr>
                </thead>
                    <hr>
                <tbody>
                <#list sgs.listData as sg>
                    <tr>
                        <td>${sg.id!}</td>
                        <td>${sg.beginTimeShow!}</td>
                        <td>${sg.endTimeShow!}</td>
                        <td>${sg.generalTypeShow!}</td>
                        <td>
                            <#if sg.generalType==0>
                                ${sg.generalWord!}
                            </#if>
                            <#if sg.generalType==1 || sg.generalType==2>
                                ${sg.resId!}
                            </#if>
                            <#if sg.generalType==4>
                                ${sg.linkUrl!}
                            </#if>
                        </td>
                        <td>
                            <div class="hidden-sm hidden-xs action-buttons">
                                <a class="green tooltip-success edit" onclick='reload("${ctx}/admin/general/edit.do?id=${sg.id!}");return false;'  data-rel="tooltip"  title="编辑" ><span class="label label-success">编辑</span></a>
                                <a class="red tooltip-error delete" href="${ctx}/admin/general/delete.do?id=${sg.id!}" data-rel="tooltip" title="删除"> <span class="label label-danger">删除</span></a>
                            </div>
                        </td>
                    </tr>
                </#list>
                </tbody>
            </table>
            <@pagination sgs!/>
            </form>
        </div>
    </div>

    <div id="editModal" class="modal fade">
        <div class="modal-dialog">
            <div class="modal-content">
            </div>
        </div>
    </div>
</@mainlayout>